package com.example.prison.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.prison.entity.DeviceAlarmRecord;
import com.example.prison.mapper.DeviceAlarmRecordMapper;
import com.example.prison.service.DeviceAlarmRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author jiang
* @description 针对表【device_alarm_record】的数据库操作Service实现
* @createDate 2023-07-04 13:56:42
*/
@Service
public class DeviceAlarmRecordServiceImpl extends ServiceImpl<DeviceAlarmRecordMapper, DeviceAlarmRecord>
    implements DeviceAlarmRecordService {

    @Autowired
    private DeviceAlarmRecordMapper alarmRecordMapper;

    @Override
    public PageInfo<DeviceAlarmRecord> get(int pageNumber, int pageSize, String beginTime, String endTime,
                                           String solve, String type) {
        PageHelper.startPage(pageNumber, pageSize);
        return new PageInfo<>(alarmRecordMapper.get(beginTime,endTime,solve,type));
    }

    @Override
    public int add(DeviceAlarmRecord record) {
        record.setSolve("未处理");
        record.setType("设备告警");
        alarmRecordMapper.add(record);
        return 1;
    }

    @Override
    public void delete(Integer[] ids) {
        alarmRecordMapper.deleteAlarmRecord(ids);
    }

    @Override
    public void handle(Integer id, String handle, String handleMessage) {
        alarmRecordMapper.handle(id, handle, handleMessage);
    }

    @Override
    public DeviceAlarmRecord getById(Integer id) {
        return alarmRecordMapper.getById(id);
    }

    @Override
    public PageInfo<DeviceAlarmRecord> getByLevel(int pageNumber, int pageSize, String alarmLevel) {
        PageHelper.startPage(pageNumber, pageSize);
        return new PageInfo<>(alarmRecordMapper.getByLevel(alarmLevel));
    }

    @Override
    public PageInfo<DeviceAlarmRecord> getByTime(int pageNumber, int pageSize, String beginTime, String endTime) {
        PageHelper.startPage(pageNumber, pageSize);
        return new PageInfo<>(alarmRecordMapper.getByTime(beginTime, endTime));
    }

}




